package com.gict.antifraudback.result;

import lombok.Data;

/**
 * @Description: restFul自定义响应类
 **/
@Data
public class ResultView {

    private Integer code;

    private String msg;

    private Object data;

    private long time;

    public static ResultView ok() {
        return new ResultView();
    }

    public static ResultView ok(Object data) {
        return new ResultView(data);
    }

    public static ResultView okMsg(String msg) {
        return new ResultView(msg);
    }

    public static ResultView error(Integer code, String msg) {
        return new ResultView(code, msg);
    }

    public static ResultView error(ResultEnum resultEnum, String msg) {
        return new ResultView(resultEnum.getCode(), msg);
    }

    public static ResultView error(ResultEnum resultEnum, Object data) {
        return new ResultView(resultEnum.getCode(), resultEnum.getMsg(), data);
    }

    public static ResultView error(ResultEnum resultEnum) {
        return new ResultView(resultEnum.getCode(), resultEnum.getMsg());
    }

    private ResultView() {
        this.code = ResultEnum.CODE_1.getCode();
        this.msg = ResultEnum.CODE_1.getMsg();
    }

    private ResultView(Object data) {
        this.data = data;
        this.code = ResultEnum.CODE_1.getCode();
        this.msg = ResultEnum.CODE_1.getMsg();
        this.time = System.currentTimeMillis();
    }

    private ResultView(String msg) {
        this.code = ResultEnum.CODE_1.getCode();
        this.msg = msg;
        this.time = System.currentTimeMillis();
    }

    private ResultView(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
        this.time = System.currentTimeMillis();
    }

    private ResultView(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.time = System.currentTimeMillis();
    }
}
